package com.pengheng.controller;

import com.pengheng.mqtt.gateway.MqttGateway;
import com.pengheng.mqtt.gateway.UAVMqttGateway;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/fun")
public class MqttFunController {

    @Autowired
    private MqttGateway mqttGateway;

    @RequestMapping("/testMqtt")
    public String sendMqtt(@RequestParam(value = "topic") String topic, @RequestParam(value = "message") String message) {
        mqttGateway.sendToMqtt(message, topic);
        return "SUCCESS";
    }

    @Autowired
    private UAVMqttGateway uavMqttGateway;

    @RequestMapping("/testUAVMqtt")
    public String sendUAVMqtt(@RequestParam(value = "topic") String topic, @RequestParam(value = "message") String message) {
        uavMqttGateway.sendToMqtt(message, topic);
        return "SUCCESS";
    }

}
